import java.util.ArrayList;
import java.util.Scanner;

//输出字符串的全排列
public class Demo4 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String str=sc.next();

        ArrayList<String> list=new ArrayList<>();
        char[] ch=str.toCharArray();
        process(ch,0,list);
        System.out.print(list+" ");
    }

    private static void process(char[] ch, int i, ArrayList<String> list) {
        if(i==ch.length)
        {
            list.add(String.valueOf(ch));
        }
        for (int j = i; j <ch.length ; j++) {
            //单纯的交换字符
            swap(ch,i,j);
            process(ch,i+1,list);
            //为了回到最刚开始的字符串，然后开始下一次的递归循环
            swap(ch,i,j);
        }
    }

    private static void swap(char[] ch, int i, int j) {
        char temp=ch[i];
        ch[i]=ch[j];
        ch[j]=temp;
    }
}
